{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "aa4bac8d",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2022-04-05T23:10:21.233392Z",
     "iopub.status.busy": "2022-04-05T23:10:21.231915Z",
     "iopub.status.idle": "2022-04-05T23:10:22.216983Z",
     "shell.execute_reply": "2022-04-05T23:10:22.216360Z",
     "shell.execute_reply.started": "2022-04-05T22:47:08.959503Z"
    },
    "id": "HbhuGdNqU_XQ",
    "papermill": {
     "duration": 1.009855,
     "end_time": "2022-04-05T23:10:22.217194",
     "exception": false,
     "start_time": "2022-04-05T23:10:21.207339",
     "status": "completed"
    },
    "tags": []
   },
   "outputs": [],
   "source": [
    "import numpy as np \n",
    "import pandas as pd \n",
    "import os\n",
    "from tqdm.auto import tqdm\n",
    "import shutil as sh\n",
    "\n",
    "from sklearn.model_selection import StratifiedKFold"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "49b9fd75",
   "metadata": {
    "papermill": {
     "duration": 0.019166,
     "end_time": "2022-04-05T23:10:22.256828",
     "exception": false,
     "start_time": "2022-04-05T23:10:22.237662",
     "status": "completed"
    },
    "tags": []
   },
   "source": [
    "# Data"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "3cbe80c7",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2022-04-05T23:10:22.300268Z",
     "iopub.status.busy": "2022-04-05T23:10:22.299430Z",
     "iopub.status.idle": "2022-04-05T23:10:22.542624Z",
     "shell.execute_reply": "2022-04-05T23:10:22.542198Z",
     "shell.execute_reply.started": "2022-04-05T22:47:08.968052Z"
    },
    "papermill": {
     "duration": 0.266499,
     "end_time": "2022-04-05T23:10:22.542741",
     "exception": false,
     "start_time": "2022-04-05T23:10:22.276242",
     "status": "completed"
    },
    "tags": []
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>image_id</th>\n",
       "      <th>width</th>\n",
       "      <th>height</th>\n",
       "      <th>bbox</th>\n",
       "      <th>source</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>b6ab77fd7</td>\n",
       "      <td>1024</td>\n",
       "      <td>1024</td>\n",
       "      <td>[834.0, 222.0, 56.0, 36.0]</td>\n",
       "      <td>usask_1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>b6ab77fd7</td>\n",
       "      <td>1024</td>\n",
       "      <td>1024</td>\n",
       "      <td>[226.0, 548.0, 130.0, 58.0]</td>\n",
       "      <td>usask_1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>b6ab77fd7</td>\n",
       "      <td>1024</td>\n",
       "      <td>1024</td>\n",
       "      <td>[377.0, 504.0, 74.0, 160.0]</td>\n",
       "      <td>usask_1</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "    image_id  width  height                         bbox   source\n",
       "0  b6ab77fd7   1024    1024   [834.0, 222.0, 56.0, 36.0]  usask_1\n",
       "1  b6ab77fd7   1024    1024  [226.0, 548.0, 130.0, 58.0]  usask_1\n",
       "2  b6ab77fd7   1024    1024  [377.0, 504.0, 74.0, 160.0]  usask_1"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# training data - bboxes\n",
    "df = pd.read_csv('../input/global-wheat-detection/train.csv')\n",
    "df.head(3)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "3c2871c7",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2022-04-05T23:10:22.602837Z",
     "iopub.status.busy": "2022-04-05T23:10:22.601909Z",
     "iopub.status.idle": "2022-04-05T23:10:23.412395Z",
     "shell.execute_reply": "2022-04-05T23:10:23.411898Z",
     "shell.execute_reply.started": "2022-04-05T22:47:09.229284Z"
    },
    "papermill": {
     "duration": 0.849402,
     "end_time": "2022-04-05T23:10:23.412536",
     "exception": false,
     "start_time": "2022-04-05T23:10:22.563134",
     "status": "completed"
    },
    "tags": []
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[834., 222.,  56.,  36.],\n",
       "       [226., 548., 130.,  58.],\n",
       "       [377., 504.,  74., 160.],\n",
       "       ...,\n",
       "       [134., 228., 141.,  71.],\n",
       "       [430.,  13., 184.,  79.],\n",
       "       [875., 740.,  94.,  61.]])"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "bboxs = np.stack(df['bbox'].apply(lambda x: np.fromstring(x[1:-1], sep=',')))\n",
    "bboxs"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "bed3dd49",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2022-04-05T23:10:23.460517Z",
     "iopub.status.busy": "2022-04-05T23:10:23.459600Z",
     "iopub.status.idle": "2022-04-05T23:10:23.493269Z",
     "shell.execute_reply": "2022-04-05T23:10:23.493676Z",
     "shell.execute_reply.started": "2022-04-05T22:47:09.863169Z"
    },
    "papermill": {
     "duration": 0.060098,
     "end_time": "2022-04-05T23:10:23.493807",
     "exception": false,
     "start_time": "2022-04-05T23:10:23.433709",
     "status": "completed"
    },
    "tags": []
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>image_id</th>\n",
       "      <th>width</th>\n",
       "      <th>height</th>\n",
       "      <th>source</th>\n",
       "      <th>x</th>\n",
       "      <th>y</th>\n",
       "      <th>w</th>\n",
       "      <th>h</th>\n",
       "      <th>x_center</th>\n",
       "      <th>y_center</th>\n",
       "      <th>classes</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>b6ab77fd7</td>\n",
       "      <td>1024</td>\n",
       "      <td>1024</td>\n",
       "      <td>usask_1</td>\n",
       "      <td>834.0</td>\n",
       "      <td>222.0</td>\n",
       "      <td>56.0</td>\n",
       "      <td>36.0</td>\n",
       "      <td>862.0</td>\n",
       "      <td>240.0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>b6ab77fd7</td>\n",
       "      <td>1024</td>\n",
       "      <td>1024</td>\n",
       "      <td>usask_1</td>\n",
       "      <td>226.0</td>\n",
       "      <td>548.0</td>\n",
       "      <td>130.0</td>\n",
       "      <td>58.0</td>\n",
       "      <td>291.0</td>\n",
       "      <td>577.0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>b6ab77fd7</td>\n",
       "      <td>1024</td>\n",
       "      <td>1024</td>\n",
       "      <td>usask_1</td>\n",
       "      <td>377.0</td>\n",
       "      <td>504.0</td>\n",
       "      <td>74.0</td>\n",
       "      <td>160.0</td>\n",
       "      <td>414.0</td>\n",
       "      <td>584.0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "    image_id  width  height   source      x      y      w      h  x_center  \\\n",
       "0  b6ab77fd7   1024    1024  usask_1  834.0  222.0   56.0   36.0     862.0   \n",
       "1  b6ab77fd7   1024    1024  usask_1  226.0  548.0  130.0   58.0     291.0   \n",
       "2  b6ab77fd7   1024    1024  usask_1  377.0  504.0   74.0  160.0     414.0   \n",
       "\n",
       "   y_center  classes  \n",
       "0     240.0        0  \n",
       "1     577.0        0  \n",
       "2     584.0        0  "
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# reformat to yolo \n",
    "for i, column in enumerate(['x', 'y', 'w', 'h']):\n",
    "    df[column] = bboxs[:,i]\n",
    "df.drop(columns=['bbox'], inplace=True)\n",
    "df['x_center'] = df['x'] + df['w']/2\n",
    "df['y_center'] = df['y'] + df['h']/2\n",
    "df['classes'] = 0\n",
    "\n",
    "df.head(3)\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "e3207747",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2022-04-05T23:10:23.546078Z",
     "iopub.status.busy": "2022-04-05T23:10:23.545306Z",
     "iopub.status.idle": "2022-04-05T23:10:23.722902Z",
     "shell.execute_reply": "2022-04-05T23:10:23.722262Z",
     "shell.execute_reply.started": "2022-04-05T22:47:09.900328Z"
    },
    "papermill": {
     "duration": 0.207886,
     "end_time": "2022-04-05T23:10:23.723030",
     "exception": false,
     "start_time": "2022-04-05T23:10:23.515144",
     "status": "completed"
    },
    "tags": []
   },
   "outputs": [],
   "source": [
    "# stratify on source\n",
    "fold_id = np.zeros((df.shape[0],1))\n",
    "\n",
    "skf = StratifiedKFold(n_splits = 5, random_state = 42, shuffle = True)\n",
    "\n",
    "for (ff, (train_index, test_index)) in enumerate(skf.split(df, df['source'])):\n",
    "    fold_id[test_index]= int(ff)\n",
    "\n",
    "df['fold'] = fold_id.copy()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "158aaf31",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2022-04-05T23:10:23.779194Z",
     "iopub.status.busy": "2022-04-05T23:10:23.778447Z",
     "iopub.status.idle": "2022-04-05T23:10:23.781191Z",
     "shell.execute_reply": "2022-04-05T23:10:23.781623Z",
     "shell.execute_reply.started": "2022-04-05T22:47:10.090136Z"
    },
    "papermill": {
     "duration": 0.037762,
     "end_time": "2022-04-05T23:10:23.781739",
     "exception": false,
     "start_time": "2022-04-05T23:10:23.743977",
     "status": "completed"
    },
    "tags": []
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>image_id</th>\n",
       "      <th>width</th>\n",
       "      <th>height</th>\n",
       "      <th>source</th>\n",
       "      <th>x</th>\n",
       "      <th>y</th>\n",
       "      <th>w</th>\n",
       "      <th>h</th>\n",
       "      <th>x_center</th>\n",
       "      <th>y_center</th>\n",
       "      <th>classes</th>\n",
       "      <th>fold</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>b6ab77fd7</td>\n",
       "      <td>1024</td>\n",
       "      <td>1024</td>\n",
       "      <td>usask_1</td>\n",
       "      <td>834.0</td>\n",
       "      <td>222.0</td>\n",
       "      <td>56.0</td>\n",
       "      <td>36.0</td>\n",
       "      <td>862.0</td>\n",
       "      <td>240.0</td>\n",
       "      <td>0</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>b6ab77fd7</td>\n",
       "      <td>1024</td>\n",
       "      <td>1024</td>\n",
       "      <td>usask_1</td>\n",
       "      <td>226.0</td>\n",
       "      <td>548.0</td>\n",
       "      <td>130.0</td>\n",
       "      <td>58.0</td>\n",
       "      <td>291.0</td>\n",
       "      <td>577.0</td>\n",
       "      <td>0</td>\n",
       "      <td>2.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>b6ab77fd7</td>\n",
       "      <td>1024</td>\n",
       "      <td>1024</td>\n",
       "      <td>usask_1</td>\n",
       "      <td>377.0</td>\n",
       "      <td>504.0</td>\n",
       "      <td>74.0</td>\n",
       "      <td>160.0</td>\n",
       "      <td>414.0</td>\n",
       "      <td>584.0</td>\n",
       "      <td>0</td>\n",
       "      <td>3.0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "    image_id  width  height   source      x      y      w      h  x_center  \\\n",
       "0  b6ab77fd7   1024    1024  usask_1  834.0  222.0   56.0   36.0     862.0   \n",
       "1  b6ab77fd7   1024    1024  usask_1  226.0  548.0  130.0   58.0     291.0   \n",
       "2  b6ab77fd7   1024    1024  usask_1  377.0  504.0   74.0  160.0     414.0   \n",
       "\n",
       "   y_center  classes  fold  \n",
       "0     240.0        0   0.0  \n",
       "1     577.0        0   2.0  \n",
       "2     584.0        0   3.0  "
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.head(3)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "5d7ead62",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2022-04-05T23:10:23.829406Z",
     "iopub.status.busy": "2022-04-05T23:10:23.828352Z",
     "iopub.status.idle": "2022-04-05T23:10:23.843517Z",
     "shell.execute_reply": "2022-04-05T23:10:23.843887Z",
     "shell.execute_reply.started": "2022-04-05T22:47:10.107328Z"
    },
    "papermill": {
     "duration": 0.040949,
     "end_time": "2022-04-05T23:10:23.844154",
     "exception": false,
     "start_time": "2022-04-05T23:10:23.803205",
     "status": "completed"
    },
    "tags": []
   },
   "outputs": [],
   "source": [
    "df = df[['image_id','x', 'y', 'w', 'h','x_center','y_center','classes', 'fold']]\n",
    "\n"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "710439da",
   "metadata": {
    "papermill": {
     "duration": 0.021324,
     "end_time": "2022-04-05T23:10:23.887077",
     "exception": false,
     "start_time": "2022-04-05T23:10:23.865753",
     "status": "completed"
    },
    "tags": []
   },
   "source": [
    "# Yolo preparation\n",
    "\n",
    "The implementation from Ultralytics has some requirements on the structure of the dataset - where the annotations are stored and the folders for training / validation data. The creation of the folders in the code below is fairly straightforward, but a more inquisitive reader is encouraged to consult the official documentation: https://github.com/ultralytics/yolov5/wiki/Train-Custom-Data\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "9a93f994",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2022-04-05T23:10:23.939662Z",
     "iopub.status.busy": "2022-04-05T23:10:23.938842Z",
     "iopub.status.idle": "2022-04-05T23:10:48.490377Z",
     "shell.execute_reply": "2022-04-05T23:10:48.490781Z",
     "shell.execute_reply.started": "2022-04-05T22:47:10.131994Z"
    },
    "papermill": {
     "duration": 24.58179,
     "end_time": "2022-04-05T23:10:48.490925",
     "exception": false,
     "start_time": "2022-04-05T23:10:23.909135",
     "status": "completed"
    },
    "tags": []
   },
   "outputs": [
    {
     "data": {
      "application/vnd.jupyter.widget-view+json": {
       "model_id": "091480d4a3c344e98cd329a608a236f3",
       "version_major": 2,
       "version_minor": 0
      },
      "text/plain": [
       "  0%|          | 0/3373 [00:00<?, ?it/s]"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "source = 'train'\n",
    "\n",
    "# pick a single fold for demonstration sake\n",
    "fold = 0 \n",
    "\n",
    "val_index = set(df[df['fold'] == fold]['image_id'])\n",
    "\n",
    "# loop through the bounding boxes per image\n",
    "for name,mini in tqdm(df.groupby('image_id')):    \n",
    "    # where to save the files\n",
    "    if name in val_index:\n",
    "        path2save = 'valid/'\n",
    "    else:\n",
    "        path2save = 'train/'   \n",
    "    # storage path for labels\n",
    "    if not os.path.exists('convertor/fold{}/labels/'.format(fold)+path2save):\n",
    "        os.makedirs('convertor/fold{}/labels/'.format(fold)+path2save)\n",
    "    with open('convertor/fold{}/labels/'.format(fold)+path2save+name+\".txt\", 'w+') as f:\n",
    "        # normalize the coordinates in accordance with the Yolo format requirements\n",
    "        row = mini[['classes','x_center','y_center','w','h']].astype(float).values\n",
    "        row = row/1024\n",
    "        row = row.astype(str)\n",
    "        for j in range(len(row)):\n",
    "            text = ' '.join(row[j])\n",
    "            f.write(text)\n",
    "            f.write(\"\\n\")\n",
    "    if not os.path.exists('convertor/fold{}/images/{}'.format(fold,path2save)):\n",
    "        os.makedirs('convertor/fold{}/images/{}'.format(fold,path2save))\n",
    "    # no preprocessing needed for images => copy them as a batch\n",
    "    sh.copy(\"../input/global-wheat-detection/{}/{}.jpg\".format(source,name),'convertor/fold{}/images/{}/{}.jpg'.format(fold,path2save,name))"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "798492d8",
   "metadata": {
    "id": "lhGrNoJjRmOW",
    "papermill": {
     "duration": 0.021402,
     "end_time": "2022-04-05T23:10:48.536698",
     "exception": false,
     "start_time": "2022-04-05T23:10:48.515296",
     "status": "completed"
    },
    "tags": []
   },
   "source": [
    "# Model"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "f5f3ed0e",
   "metadata": {
    "papermill": {
     "duration": 0.021257,
     "end_time": "2022-04-05T23:10:48.579623",
     "exception": false,
     "start_time": "2022-04-05T23:10:48.558366",
     "status": "completed"
    },
    "tags": []
   },
   "source": [
    "Actual Yolo"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "id": "9167d43b",
   "metadata": {
    "_kg_hide-output": true,
    "execution": {
     "iopub.execute_input": "2022-04-05T23:10:48.627391Z",
     "iopub.status.busy": "2022-04-05T23:10:48.624814Z",
     "iopub.status.idle": "2022-04-05T23:11:00.071039Z",
     "shell.execute_reply": "2022-04-05T23:11:00.070530Z",
     "shell.execute_reply.started": "2022-04-05T22:47:42.537554Z"
    },
    "id": "ZHQ-05_nQau2",
    "papermill": {
     "duration": 11.470109,
     "end_time": "2022-04-05T23:11:00.071232",
     "exception": false,
     "start_time": "2022-04-05T23:10:48.601123",
     "status": "completed"
    },
    "tags": []
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Cloning into 'yolov5'...\r\n",
      "remote: Enumerating objects: 12530, done.\u001b[K\r\n",
      "remote: Counting objects: 100% (19/19), done.\u001b[K\r\n",
      "remote: Compressing objects: 100% (12/12), done.\u001b[K\r\n",
      "remote: Total 12530 (delta 7), reused 17 (delta 7), pack-reused 12511\u001b[K\r\n",
      "Receiving objects: 100% (12530/12530), 11.62 MiB | 21.32 MiB/s, done.\r\n",
      "Resolving deltas: 100% (8715/8715), done.\r\n",
      "Requirement already satisfied: matplotlib>=3.2.2 in /opt/conda/lib/python3.7/site-packages (from -r requirements.txt (line 4)) (3.5.1)\r\n",
      "Requirement already satisfied: numpy>=1.18.5 in /opt/conda/lib/python3.7/site-packages (from -r requirements.txt (line 5)) (1.20.3)\r\n",
      "Requirement already satisfied: opencv-python>=4.1.2 in /opt/conda/lib/python3.7/site-packages (from -r requirements.txt (line 6)) (4.5.4.60)\r\n",
      "Requirement already satisfied: Pillow>=7.1.2 in /opt/conda/lib/python3.7/site-packages (from -r requirements.txt (line 7)) (8.2.0)\r\n",
      "Requirement already satisfied: PyYAML>=5.3.1 in /opt/conda/lib/python3.7/site-packages (from -r requirements.txt (line 8)) (6.0)\r\n",
      "Requirement already satisfied: requests>=2.23.0 in /opt/conda/lib/python3.7/site-packages (from -r requirements.txt (line 9)) (2.26.0)\r\n",
      "Requirement already satisfied: scipy>=1.4.1 in /opt/conda/lib/python3.7/site-packages (from -r requirements.txt (line 10)) (1.7.3)\r\n",
      "Requirement already satisfied: torch>=1.7.0 in /opt/conda/lib/python3.7/site-packages (from -r requirements.txt (line 11)) (1.9.1)\r\n",
      "Requirement already satisfied: torchvision>=0.8.1 in /opt/conda/lib/python3.7/site-packages (from -r requirements.txt (line 12)) (0.10.1)\r\n",
      "Requirement already satisfied: tqdm>=4.41.0 in /opt/conda/lib/python3.7/site-packages (from -r requirements.txt (line 13)) (4.62.3)\r\n",
      "Requirement already satisfied: tensorboard>=2.4.1 in /opt/conda/lib/python3.7/site-packages (from -r requirements.txt (line 16)) (2.6.0)\r\n",
      "Requirement already satisfied: pandas>=1.1.4 in /opt/conda/lib/python3.7/site-packages (from -r requirements.txt (line 20)) (1.3.5)\r\n",
      "Requirement already satisfied: seaborn>=0.11.0 in /opt/conda/lib/python3.7/site-packages (from -r requirements.txt (line 21)) (0.11.2)\r\n",
      "Collecting thop\r\n",
      "  Downloading thop-0.0.31.post2005241907-py3-none-any.whl (8.7 kB)\r\n",
      "Requirement already satisfied: python-dateutil>=2.7 in /opt/conda/lib/python3.7/site-packages (from matplotlib>=3.2.2->-r requirements.txt (line 4)) (2.8.2)\r\n",
      "Requirement already satisfied: kiwisolver>=1.0.1 in /opt/conda/lib/python3.7/site-packages (from matplotlib>=3.2.2->-r requirements.txt (line 4)) (1.3.2)\r\n",
      "Requirement already satisfied: cycler>=0.10 in /opt/conda/lib/python3.7/site-packages (from matplotlib>=3.2.2->-r requirements.txt (line 4)) (0.11.0)\r\n",
      "Requirement already satisfied: fonttools>=4.22.0 in /opt/conda/lib/python3.7/site-packages (from matplotlib>=3.2.2->-r requirements.txt (line 4)) (4.28.4)\r\n",
      "Requirement already satisfied: pyparsing>=2.2.1 in /opt/conda/lib/python3.7/site-packages (from matplotlib>=3.2.2->-r requirements.txt (line 4)) (3.0.6)\r\n",
      "Requirement already satisfied: packaging>=20.0 in /opt/conda/lib/python3.7/site-packages (from matplotlib>=3.2.2->-r requirements.txt (line 4)) (21.3)\r\n",
      "Requirement already satisfied: certifi>=2017.4.17 in /opt/conda/lib/python3.7/site-packages (from requests>=2.23.0->-r requirements.txt (line 9)) (2021.10.8)\r\n",
      "Requirement already satisfied: urllib3<1.27,>=1.21.1 in /opt/conda/lib/python3.7/site-packages (from requests>=2.23.0->-r requirements.txt (line 9)) (1.26.7)\r\n",
      "Requirement already satisfied: charset-normalizer~=2.0.0 in /opt/conda/lib/python3.7/site-packages (from requests>=2.23.0->-r requirements.txt (line 9)) (2.0.9)\r\n",
      "Requirement already satisfied: idna<4,>=2.5 in /opt/conda/lib/python3.7/site-packages (from requests>=2.23.0->-r requirements.txt (line 9)) (3.1)\r\n",
      "Requirement already satisfied: typing-extensions in /opt/conda/lib/python3.7/site-packages (from torch>=1.7.0->-r requirements.txt (line 11)) (4.1.1)\r\n",
      "Requirement already satisfied: google-auth<2,>=1.6.3 in /opt/conda/lib/python3.7/site-packages (from tensorboard>=2.4.1->-r requirements.txt (line 16)) (1.35.0)\r\n",
      "Requirement already satisfied: absl-py>=0.4 in /opt/conda/lib/python3.7/site-packages (from tensorboard>=2.4.1->-r requirements.txt (line 16)) (0.15.0)\r\n",
      "Requirement already satisfied: wheel>=0.26 in /opt/conda/lib/python3.7/site-packages (from tensorboard>=2.4.1->-r requirements.txt (line 16)) (0.37.0)\r\n",
      "Requirement already satisfied: grpcio>=1.24.3 in /opt/conda/lib/python3.7/site-packages (from tensorboard>=2.4.1->-r requirements.txt (line 16)) (1.43.0)\r\n",
      "Requirement already satisfied: protobuf>=3.6.0 in /opt/conda/lib/python3.7/site-packages (from tensorboard>=2.4.1->-r requirements.txt (line 16)) (3.19.4)\r\n",
      "Requirement already satisfied: tensorboard-plugin-wit>=1.6.0 in /opt/conda/lib/python3.7/site-packages (from tensorboard>=2.4.1->-r requirements.txt (line 16)) (1.8.0)\r\n",
      "Requirement already satisfied: setuptools>=41.0.0 in /opt/conda/lib/python3.7/site-packages (from tensorboard>=2.4.1->-r requirements.txt (line 16)) (59.5.0)\r\n",
      "Requirement already satisfied: tensorboard-data-server<0.7.0,>=0.6.0 in /opt/conda/lib/python3.7/site-packages (from tensorboard>=2.4.1->-r requirements.txt (line 16)) (0.6.1)\r\n",
      "Requirement already satisfied: werkzeug>=0.11.15 in /opt/conda/lib/python3.7/site-packages (from tensorboard>=2.4.1->-r requirements.txt (line 16)) (2.0.2)\r\n",
      "Requirement already satisfied: markdown>=2.6.8 in /opt/conda/lib/python3.7/site-packages (from tensorboard>=2.4.1->-r requirements.txt (line 16)) (3.3.6)\r\n",
      "Requirement already satisfied: google-auth-oauthlib<0.5,>=0.4.1 in /opt/conda/lib/python3.7/site-packages (from tensorboard>=2.4.1->-r requirements.txt (line 16)) (0.4.6)\r\n",
      "Requirement already satisfied: pytz>=2017.3 in /opt/conda/lib/python3.7/site-packages (from pandas>=1.1.4->-r requirements.txt (line 20)) (2021.3)\r\n",
      "Requirement already satisfied: six in /opt/conda/lib/python3.7/site-packages (from absl-py>=0.4->tensorboard>=2.4.1->-r requirements.txt (line 16)) (1.16.0)\r\n",
      "Requirement already satisfied: cachetools<5.0,>=2.0.0 in /opt/conda/lib/python3.7/site-packages (from google-auth<2,>=1.6.3->tensorboard>=2.4.1->-r requirements.txt (line 16)) (4.2.4)\r\n",
      "Requirement already satisfied: pyasn1-modules>=0.2.1 in /opt/conda/lib/python3.7/site-packages (from google-auth<2,>=1.6.3->tensorboard>=2.4.1->-r requirements.txt (line 16)) (0.2.7)\r\n",
      "Requirement already satisfied: rsa<5,>=3.1.4 in /opt/conda/lib/python3.7/site-packages (from google-auth<2,>=1.6.3->tensorboard>=2.4.1->-r requirements.txt (line 16)) (4.8)\r\n",
      "Requirement already satisfied: requests-oauthlib>=0.7.0 in /opt/conda/lib/python3.7/site-packages (from google-auth-oauthlib<0.5,>=0.4.1->tensorboard>=2.4.1->-r requirements.txt (line 16)) (1.3.0)\r\n",
      "Requirement already satisfied: importlib-metadata>=4.4 in /opt/conda/lib/python3.7/site-packages (from markdown>=2.6.8->tensorboard>=2.4.1->-r requirements.txt (line 16)) (4.11.3)\r\n",
      "Requirement already satisfied: zipp>=0.5 in /opt/conda/lib/python3.7/site-packages (from importlib-metadata>=4.4->markdown>=2.6.8->tensorboard>=2.4.1->-r requirements.txt (line 16)) (3.6.0)\r\n",
      "Requirement already satisfied: pyasn1<0.5.0,>=0.4.6 in /opt/conda/lib/python3.7/site-packages (from pyasn1-modules>=0.2.1->google-auth<2,>=1.6.3->tensorboard>=2.4.1->-r requirements.txt (line 16)) (0.4.8)\r\n",
      "Requirement already satisfied: oauthlib>=3.0.0 in /opt/conda/lib/python3.7/site-packages (from requests-oauthlib>=0.7.0->google-auth-oauthlib<0.5,>=0.4.1->tensorboard>=2.4.1->-r requirements.txt (line 16)) (3.1.1)\r\n",
      "Installing collected packages: thop\r\n",
      "Successfully installed thop-0.0.31.post2005241907\r\n",
      "\u001b[33mWARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv\u001b[0m\r\n"
     ]
    }
   ],
   "source": [
    "!git clone https://github.com/ultralytics/yolov5  && cd yolov5 && pip install -r requirements.txt  "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "id": "552b5479",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2022-04-05T23:11:00.142037Z",
     "iopub.status.busy": "2022-04-05T23:11:00.141491Z",
     "iopub.status.idle": "2022-04-05T23:11:00.195843Z",
     "shell.execute_reply": "2022-04-05T23:11:00.196374Z",
     "shell.execute_reply.started": "2022-04-05T22:47:53.902335Z"
    },
    "id": "JmV_1FB0ubO5",
    "outputId": "fa163529-9b98-44ca-ed87-d3a79579b11b",
    "papermill": {
     "duration": 0.092599,
     "end_time": "2022-04-05T23:11:00.196527",
     "exception": false,
     "start_time": "2022-04-05T23:11:00.103928",
     "status": "completed"
    },
    "tags": []
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Tue Apr  5 23:11:00 2022       \n",
      "+-----------------------------------------------------------------------------+\n",
      "| NVIDIA-SMI 450.119.04   Driver Version: 450.119.04   CUDA Version: 11.0     |\n",
      "|-------------------------------+----------------------+----------------------+\n",
      "| GPU  Name        Persistence-M| Bus-Id        Disp.A | Volatile Uncorr. ECC |\n",
      "| Fan  Temp  Perf  Pwr:Usage/Cap|         Memory-Usage | GPU-Util  Compute M. |\n",
      "|                               |                      |               MIG M. |\n",
      "|===============================+======================+======================|\n",
      "|   0  Tesla P100-PCIE...  Off  | 00000000:00:04.0 Off |                    0 |\n",
      "| N/A   37C    P0    26W / 250W |      0MiB / 16280MiB |      0%      Default |\n",
      "|                               |                      |                  N/A |\n",
      "+-------------------------------+----------------------+----------------------+\n",
      "                                                                               \n",
      "+-----------------------------------------------------------------------------+\n",
      "| Processes:                                                                  |\n",
      "|  GPU   GI   CI        PID   Type   Process name                  GPU Memory |\n",
      "|        ID   ID                                                   Usage      |\n",
      "|=============================================================================|\n",
      "|  No running processes found                                                 |\n",
      "+-----------------------------------------------------------------------------+\n"
     ]
    }
   ],
   "source": [
    "# check the assigned GPU type\n",
    "gpu_info = !nvidia-smi\n",
    "gpu_info = '\\n'.join(gpu_info)\n",
    "if gpu_info.find('failed') >= 0:\n",
    "    print('Select the Runtime > \"Change runtime type\" menu to enable a GPU accelerator, ')\n",
    "    print('and then re-execute this cell.')\n",
    "    \n",
    "else:\n",
    "    print(gpu_info)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "id": "e3882cc7",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2022-04-05T23:11:00.267113Z",
     "iopub.status.busy": "2022-04-05T23:11:00.266463Z",
     "iopub.status.idle": "2022-04-05T23:11:00.269050Z",
     "shell.execute_reply": "2022-04-05T23:11:00.268631Z",
     "shell.execute_reply.started": "2022-04-05T22:47:53.959852Z"
    },
    "papermill": {
     "duration": 0.040344,
     "end_time": "2022-04-05T23:11:00.269162",
     "exception": false,
     "start_time": "2022-04-05T23:11:00.228818",
     "status": "completed"
    },
    "tags": []
   },
   "outputs": [],
   "source": [
    "yaml_text = \"\"\"train: /kaggle/working/convertor/fold0/images/train/\n",
    "val: /kaggle/working/convertor/fold0/images/valid/\n",
    "\n",
    "nc: 1\n",
    "names: ['wheat']\"\"\""
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "id": "3cbb1131",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2022-04-05T23:11:00.338587Z",
     "iopub.status.busy": "2022-04-05T23:11:00.337739Z",
     "iopub.status.idle": "2022-04-05T23:11:01.037285Z",
     "shell.execute_reply": "2022-04-05T23:11:01.036127Z",
     "shell.execute_reply.started": "2022-04-05T22:47:53.966210Z"
    },
    "papermill": {
     "duration": 0.735953,
     "end_time": "2022-04-05T23:11:01.037436",
     "exception": false,
     "start_time": "2022-04-05T23:11:00.301483",
     "status": "completed"
    },
    "tags": []
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "train: /kaggle/working/convertor/fold0/images/train/\r\n",
      "val: /kaggle/working/convertor/fold0/images/valid/\r\n",
      "\r\n",
      "nc: 1\r\n",
      "names: ['wheat']"
     ]
    }
   ],
   "source": [
    "with open(\"wheat.yaml\", 'w') as f:\n",
    "    f.write(yaml_text)\n",
    "%cat wheat.yaml"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "id": "5dcf2a7a",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2022-04-05T23:11:01.108993Z",
     "iopub.status.busy": "2022-04-05T23:11:01.108293Z",
     "iopub.status.idle": "2022-04-05T23:18:25.886224Z",
     "shell.execute_reply": "2022-04-05T23:18:25.885105Z",
     "shell.execute_reply.started": "2022-04-05T22:47:54.635450Z"
    },
    "papermill": {
     "duration": 444.816019,
     "end_time": "2022-04-05T23:18:25.886369",
     "exception": false,
     "start_time": "2022-04-05T23:11:01.070350",
     "status": "completed"
    },
    "tags": []
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Downloading https://ultralytics.com/assets/Arial.ttf to /root/.config/Ultralytics/Arial.ttf...\r\n",
      "\u001b[34m\u001b[1mwandb\u001b[0m: (1) Create a W&B account\r\n",
      "\u001b[34m\u001b[1mwandb\u001b[0m: (2) Use an existing W&B account\r\n",
      "\u001b[34m\u001b[1mwandb\u001b[0m: (3) Don't visualize my results\r\n",
      "\u001b[34m\u001b[1mwandb\u001b[0m: Enter your choice: (30 second timeout) \r\n",
      "\u001b[34m\u001b[1mwandb\u001b[0m: W&B disabled due to login timeout.\r\n",
      "\u001b[34m\u001b[1mtrain: \u001b[0mweights=yolov5/yolov5s.pt, cfg=./yolov5/models/yolov5s.yaml, data=wheat.yaml, hyp=yolov5/data/hyps/hyp.scratch-low.yaml, epochs=3, batch_size=2, imgsz=512, rect=False, resume=False, nosave=False, noval=False, noautoanchor=False, evolve=None, bucket=, cache=ram, image_weights=False, device=, multi_scale=False, single_cls=False, optimizer=SGD, sync_bn=False, workers=2, project=yolov5/runs/train, name=yolov5x_fold0, exist_ok=False, quad=False, cos_lr=False, label_smoothing=0.0, patience=100, freeze=[0], save_period=-1, local_rank=-1, entity=None, upload_dataset=False, bbox_interval=-1, artifact_alias=latest\r\n",
      "\u001b[34m\u001b[1mgithub: \u001b[0mup to date with https://github.com/ultralytics/yolov5 ✅\r\n",
      "YOLOv5 🚀 v6.1-105-gd257c75 torch 1.9.1 CUDA:0 (Tesla P100-PCIE-16GB, 16281MiB)\r\n",
      "\r\n",
      "\u001b[34m\u001b[1mhyperparameters: \u001b[0mlr0=0.01, lrf=0.01, momentum=0.937, weight_decay=0.0005, warmup_epochs=3.0, warmup_momentum=0.8, warmup_bias_lr=0.1, box=0.05, cls=0.5, cls_pw=1.0, obj=1.0, obj_pw=1.0, iou_t=0.2, anchor_t=4.0, fl_gamma=0.0, hsv_h=0.015, hsv_s=0.7, hsv_v=0.4, degrees=0.0, translate=0.1, scale=0.5, shear=0.0, perspective=0.0, flipud=0.0, fliplr=0.5, mosaic=1.0, mixup=0.0, copy_paste=0.0\r\n",
      "\u001b[34m\u001b[1mWeights & Biases: \u001b[0mrun 'pip install wandb' to automatically track and visualize YOLOv5 🚀 runs (RECOMMENDED)\r\n",
      "\u001b[34m\u001b[1mTensorBoard: \u001b[0mStart with 'tensorboard --logdir yolov5/runs/train', view at http://localhost:6006/\r\n",
      "Downloading https://github.com/ultralytics/yolov5/releases/download/v6.1/yolov5s.pt to yolov5/yolov5s.pt...\r\n",
      "100%|██████████████████████████████████████| 14.1M/14.1M [00:00<00:00, 31.4MB/s]\r\n",
      "\r\n",
      "Overriding model.yaml nc=80 with nc=1\r\n",
      "\r\n",
      "                 from  n    params  module                                  arguments                     \r\n",
      "  0                -1  1      3520  models.common.Conv                      [3, 32, 6, 2, 2]              \r\n",
      "  1                -1  1     18560  models.common.Conv                      [32, 64, 3, 2]                \r\n",
      "  2                -1  1     18816  models.common.C3                        [64, 64, 1]                   \r\n",
      "  3                -1  1     73984  models.common.Conv                      [64, 128, 3, 2]               \r\n",
      "  4                -1  2    115712  models.common.C3                        [128, 128, 2]                 \r\n",
      "  5                -1  1    295424  models.common.Conv                      [128, 256, 3, 2]              \r\n",
      "  6                -1  3    625152  models.common.C3                        [256, 256, 3]                 \r\n",
      "  7                -1  1   1180672  models.common.Conv                      [256, 512, 3, 2]              \r\n",
      "  8                -1  1   1182720  models.common.C3                        [512, 512, 1]                 \r\n",
      "  9                -1  1    656896  models.common.SPPF                      [512, 512, 5]                 \r\n",
      " 10                -1  1    131584  models.common.Conv                      [512, 256, 1, 1]              \r\n",
      " 11                -1  1         0  torch.nn.modules.upsampling.Upsample    [None, 2, 'nearest']          \r\n",
      " 12           [-1, 6]  1         0  models.common.Concat                    [1]                           \r\n",
      " 13                -1  1    361984  models.common.C3                        [512, 256, 1, False]          \r\n",
      " 14                -1  1     33024  models.common.Conv                      [256, 128, 1, 1]              \r\n",
      " 15                -1  1         0  torch.nn.modules.upsampling.Upsample    [None, 2, 'nearest']          \r\n",
      " 16           [-1, 4]  1         0  models.common.Concat                    [1]                           \r\n",
      " 17                -1  1     90880  models.common.C3                        [256, 128, 1, False]          \r\n",
      " 18                -1  1    147712  models.common.Conv                      [128, 128, 3, 2]              \r\n",
      " 19          [-1, 14]  1         0  models.common.Concat                    [1]                           \r\n",
      " 20                -1  1    296448  models.common.C3                        [256, 256, 1, False]          \r\n",
      " 21                -1  1    590336  models.common.Conv                      [256, 256, 3, 2]              \r\n",
      " 22          [-1, 10]  1         0  models.common.Concat                    [1]                           \r\n",
      " 23                -1  1   1182720  models.common.C3                        [512, 512, 1, False]          \r\n",
      " 24      [17, 20, 23]  1     16182  models.yolo.Detect                      [1, [[10, 13, 16, 30, 33, 23], [30, 61, 62, 45, 59, 119], [116, 90, 156, 198, 373, 326]], [128, 256, 512]]\r\n",
      "YOLOv5s summary: 270 layers, 7022326 parameters, 7022326 gradients, 15.8 GFLOPs\r\n",
      "\r\n",
      "Transferred 342/349 items from yolov5/yolov5s.pt\r\n",
      "Scaled weight_decay = 0.0005\r\n",
      "\u001b[34m\u001b[1moptimizer:\u001b[0m SGD with parameter groups 57 weight (no decay), 60 weight, 60 bias\r\n",
      "\u001b[34m\u001b[1malbumentations: \u001b[0mBlur(always_apply=False, p=0.01, blur_limit=(3, 7)), MedianBlur(always_apply=False, p=0.01, blur_limit=(3, 7)), ToGray(always_apply=False, p=0.01), CLAHE(always_apply=False, p=0.01, clip_limit=(1, 4.0), tile_grid_size=(8, 8))\r\n",
      "\u001b[34m\u001b[1mtrain: \u001b[0mScanning '/kaggle/working/convertor/fold0/labels/train' images and labels\u001b[0m\r\n",
      "\u001b[34m\u001b[1mtrain: \u001b[0mNew cache created: /kaggle/working/convertor/fold0/labels/train.cache\r\n",
      "\u001b[34m\u001b[1mtrain: \u001b[0mCaching images (0.0GB ram): 100%|██████████| 51/51 [00:00<00:00, 74.90it/\u001b[0m\r\n",
      "\u001b[34m\u001b[1mval: \u001b[0mScanning '/kaggle/working/convertor/fold0/labels/valid' images and labels..\u001b[0m\r\n",
      "\u001b[34m\u001b[1mval: \u001b[0mNew cache created: /kaggle/working/convertor/fold0/labels/valid.cache\r\n",
      "\u001b[34m\u001b[1mval: \u001b[0mCaching images (2.6GB ram): 100%|██████████| 3322/3322 [00:45<00:00, 72.68i\u001b[0m\r\n",
      "Plotting labels to yolov5/runs/train/yolov5x_fold0/labels.jpg... \r\n",
      "\r\n",
      "\u001b[34m\u001b[1mAutoAnchor: \u001b[0m6.00 anchors/target, 0.997 Best Possible Recall (BPR). Current anchors are a good fit to dataset ✅\r\n",
      "Image sizes 512 train, 512 val\r\n",
      "Using 2 dataloader workers\r\n",
      "Logging results to \u001b[1myolov5/runs/train/yolov5x_fold0\u001b[0m\r\n",
      "Starting training for 3 epochs...\r\n",
      "\r\n",
      "     Epoch   gpu_mem       box       obj       cls    labels  img_size\r\n",
      "       0/2    0.371G    0.1196   0.05478         0        14       512: 100%|███\r\n",
      "               Class     Images     Labels          P          R     mAP@.5 mAP@\r\n",
      "                 all       3322     147409    0.00773     0.0523    0.00436   0.000951\r\n",
      "\r\n",
      "     Epoch   gpu_mem       box       obj       cls    labels  img_size\r\n",
      "       1/2    0.474G    0.1176   0.05624         0         5       512: 100%|███\r\n",
      "               Class     Images     Labels          P          R     mAP@.5 mAP@\r\n",
      "                 all       3322     147409    0.00915     0.0618    0.00494    0.00108\r\n",
      "\r\n",
      "     Epoch   gpu_mem       box       obj       cls    labels  img_size\r\n",
      "       2/2    0.474G    0.1146   0.06306         0        12       512: 100%|███\r\n",
      "               Class     Images     Labels          P          R     mAP@.5 mAP@\r\n",
      "                 all       3322     147409    0.00999     0.0676    0.00562    0.00123\r\n",
      "\r\n",
      "3 epochs completed in 0.070 hours.\r\n",
      "Optimizer stripped from yolov5/runs/train/yolov5x_fold0/weights/last.pt, 14.4MB\r\n",
      "Optimizer stripped from yolov5/runs/train/yolov5x_fold0/weights/best.pt, 14.4MB\r\n",
      "\r\n",
      "Validating yolov5/runs/train/yolov5x_fold0/weights/best.pt...\r\n",
      "Fusing layers... \r\n",
      "YOLOv5s summary: 213 layers, 7012822 parameters, 0 gradients, 15.8 GFLOPs\r\n",
      "               Class     Images     Labels          P          R     mAP@.5 mAP@WARNING: NMS time limit 0.220s exceeded\r\n",
      "               Class     Images     Labels          P          R     mAP@.5 mAP@\r\n",
      "                 all       3322     147409       0.01     0.0674    0.00558    0.00123\r\n",
      "Results saved to \u001b[1myolov5/runs/train/yolov5x_fold0\u001b[0m\r\n",
      "Exception ignored in: <function _MultiProcessingDataLoaderIter.__del__ at 0x7ff244e3d560>\r\n",
      "Traceback (most recent call last):\r\n",
      "  File \"/opt/conda/lib/python3.7/site-packages/torch/utils/data/dataloader.py\", line 1328, in __del__\r\n",
      "  File \"/opt/conda/lib/python3.7/site-packages/torch/utils/data/dataloader.py\", line 1262, in _shutdown_workers\r\n",
      "AttributeError: 'NoneType' object has no attribute 'python_exit_status'\r\n",
      "Exception ignored in: <function _MultiProcessingDataLoaderIter.__del__ at 0x7ff244e3d560>\r\n",
      "Traceback (most recent call last):\r\n",
      "  File \"/opt/conda/lib/python3.7/site-packages/torch/utils/data/dataloader.py\", line 1328, in __del__\r\n",
      "  File \"/opt/conda/lib/python3.7/site-packages/torch/utils/data/dataloader.py\", line 1262, in _shutdown_workers\r\n",
      "AttributeError: 'NoneType' object has no attribute 'python_exit_status'\r\n"
     ]
    }
   ],
   "source": [
    "!python ./yolov5/train.py --img 512 --batch 2 --epochs 3 --workers 2 --data wheat.yaml --cfg \"./yolov5/models/yolov5s.yaml\" --name yolov5x_fold0 --cache"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "id": "77aa6f68",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2022-04-05T23:18:27.643877Z",
     "iopub.status.busy": "2022-04-05T23:18:27.643175Z",
     "iopub.status.idle": "2022-04-05T23:18:28.301355Z",
     "shell.execute_reply": "2022-04-05T23:18:28.300843Z",
     "shell.execute_reply.started": "2022-04-05T22:55:18.529786Z"
    },
    "papermill": {
     "duration": 1.645305,
     "end_time": "2022-04-05T23:18:28.301484",
     "exception": false,
     "start_time": "2022-04-05T23:18:26.656179",
     "status": "completed"
    },
    "tags": []
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "total 28M\r\n",
      "-rw-r--r-- 1 root root 14M Apr  5 23:16 best.pt\r\n",
      "-rw-r--r-- 1 root root 14M Apr  5 23:16 last.pt\r\n"
     ]
    }
   ],
   "source": [
    "!ls ./yolov5/runs/train/yolov5x_fold0/weights/ -lh"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "0c903ad1",
   "metadata": {
    "id": "73UFu27oXE_R",
    "papermill": {
     "duration": 0.739443,
     "end_time": "2022-04-05T23:18:29.783136",
     "exception": false,
     "start_time": "2022-04-05T23:18:29.043693",
     "status": "completed"
    },
    "tags": []
   },
   "source": [
    "# Prediction"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "id": "e0224adb",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2022-04-05T23:18:31.331297Z",
     "iopub.status.busy": "2022-04-05T23:18:31.330564Z",
     "iopub.status.idle": "2022-04-05T23:18:31.998651Z",
     "shell.execute_reply": "2022-04-05T23:18:31.998199Z",
     "shell.execute_reply.started": "2022-04-05T22:55:52.805882Z"
    },
    "papermill": {
     "duration": 1.472874,
     "end_time": "2022-04-05T23:18:31.998774",
     "exception": false,
     "start_time": "2022-04-05T23:18:30.525900",
     "status": "completed"
    },
    "tags": []
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "2fd875eaa.jpg  51b3e36ab.jpg  53f253011.jpg  aac893a91.jpg  cc3532ff6.jpg\r\n",
      "348a992bb.jpg  51f1be19e.jpg  796707dd7.jpg  cb8d261a3.jpg  f5a1f0358.jpg\r\n"
     ]
    }
   ],
   "source": [
    "!ls /kaggle/input/global-wheat-detection/test"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "id": "16b7e25a",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2022-04-05T23:18:33.480559Z",
     "iopub.status.busy": "2022-04-05T23:18:33.479703Z",
     "iopub.status.idle": "2022-04-05T23:18:41.724424Z",
     "shell.execute_reply": "2022-04-05T23:18:41.723916Z",
     "shell.execute_reply.started": "2022-04-05T22:55:55.248970Z"
    },
    "id": "m4SUWEUSmTB8",
    "outputId": "f1c4183a-11c9-456b-dbcd-c8ed60ac479d",
    "papermill": {
     "duration": 8.989914,
     "end_time": "2022-04-05T23:18:41.724570",
     "exception": false,
     "start_time": "2022-04-05T23:18:32.734656",
     "status": "completed"
    },
    "tags": []
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\u001b[34m\u001b[1mdetect: \u001b[0mweights=['./yolov5/runs/train/yolov5x_fold0/weights/best.pt'], source=/kaggle/input/global-wheat-detection/test, data=yolov5/data/coco128.yaml, imgsz=[512, 512], conf_thres=0.1, iou_thres=0.45, max_det=1000, device=, view_img=False, save_txt=True, save_conf=True, save_crop=False, nosave=False, classes=None, agnostic_nms=False, augment=False, visualize=False, update=False, project=yolov5/runs/detect, name=exp, exist_ok=True, line_thickness=3, hide_labels=False, hide_conf=False, half=False, dnn=False\r\n",
      "YOLOv5 🚀 v6.1-105-gd257c75 torch 1.9.1 CUDA:0 (Tesla P100-PCIE-16GB, 16281MiB)\r\n",
      "\r\n",
      "Fusing layers... \r\n",
      "YOLOv5s summary: 213 layers, 7012822 parameters, 0 gradients, 15.8 GFLOPs\r\n",
      "image 1/10 /kaggle/input/global-wheat-detection/test/2fd875eaa.jpg: 512x512 2 wheats, Done. (0.018s)\r\n",
      "image 2/10 /kaggle/input/global-wheat-detection/test/348a992bb.jpg: 512x512 2 wheats, Done. (0.018s)\r\n",
      "image 3/10 /kaggle/input/global-wheat-detection/test/51b3e36ab.jpg: 512x512 Done. (0.018s)\r\n",
      "image 4/10 /kaggle/input/global-wheat-detection/test/51f1be19e.jpg: 512x512 Done. (0.019s)\r\n",
      "image 5/10 /kaggle/input/global-wheat-detection/test/53f253011.jpg: 512x512 6 wheats, Done. (0.020s)\r\n",
      "image 6/10 /kaggle/input/global-wheat-detection/test/796707dd7.jpg: 512x512 1 wheat, Done. (0.020s)\r\n",
      "image 7/10 /kaggle/input/global-wheat-detection/test/aac893a91.jpg: 512x512 1 wheat, Done. (0.018s)\r\n",
      "image 8/10 /kaggle/input/global-wheat-detection/test/cb8d261a3.jpg: 512x512 Done. (0.018s)\r\n",
      "image 9/10 /kaggle/input/global-wheat-detection/test/cc3532ff6.jpg: 512x512 7 wheats, Done. (0.018s)\r\n",
      "image 10/10 /kaggle/input/global-wheat-detection/test/f5a1f0358.jpg: 512x512 1 wheat, Done. (0.018s)\r\n",
      "Speed: 0.4ms pre-process, 18.7ms inference, 1.0ms NMS per image at shape (1, 3, 512, 512)\r\n",
      "Results saved to \u001b[1myolov5/runs/detect/exp\u001b[0m\r\n",
      "7 labels saved to yolov5/runs/detect/exp/labels\r\n"
     ]
    }
   ],
   "source": [
    "!python ./yolov5/detect.py --weights ./yolov5/runs/train/yolov5x_fold0/weights/best.pt --img 512 --conf 0.1 --source /kaggle/input/global-wheat-detection/test --save-txt --save-conf --exist-ok"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "id": "875d31e8",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2022-04-05T23:18:43.217850Z",
     "iopub.status.busy": "2022-04-05T23:18:43.217150Z",
     "iopub.status.idle": "2022-04-05T23:18:43.868418Z",
     "shell.execute_reply": "2022-04-05T23:18:43.867748Z",
     "shell.execute_reply.started": "2022-04-05T22:56:06.709631Z"
    },
    "id": "2iP0NH65GmYu",
    "outputId": "244d9f4a-1179-471f-d598-24b10677c3fa",
    "papermill": {
     "duration": 1.399162,
     "end_time": "2022-04-05T23:18:43.868557",
     "exception": false,
     "start_time": "2022-04-05T23:18:42.469395",
     "status": "completed"
    },
    "tags": []
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "2fd875eaa.txt  53f253011.txt  aac893a91.txt  f5a1f0358.txt\r\n",
      "348a992bb.txt  796707dd7.txt  cc3532ff6.txt\r\n"
     ]
    }
   ],
   "source": [
    "!ls ./yolov5/runs/detect/exp/labels/"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "id": "5c48a08a",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2022-04-05T23:18:45.367612Z",
     "iopub.status.busy": "2022-04-05T23:18:45.366750Z",
     "iopub.status.idle": "2022-04-05T23:18:45.368504Z",
     "shell.execute_reply": "2022-04-05T23:18:45.368988Z"
    },
    "papermill": {
     "duration": 0.753379,
     "end_time": "2022-04-05T23:18:45.369139",
     "exception": false,
     "start_time": "2022-04-05T23:18:44.615760",
     "status": "completed"
    },
    "tags": []
   },
   "outputs": [],
   "source": [
    "def convert(s):\n",
    "    x = int(1024 * (s[1] - s[3]/2))\n",
    "    y = int(1024 * (s[2] - s[4]/2))\n",
    "    w = int(1024 * s[3])\n",
    "    h = int(1024 * s[4])\n",
    "    \n",
    "    return(str(s[5]) + ' ' + str(x) + ' ' + str(y) + ' ' + str(w) + ' ' + str(h))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "id": "f30c95fc",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2022-04-05T23:18:46.871794Z",
     "iopub.status.busy": "2022-04-05T23:18:46.870885Z",
     "iopub.status.idle": "2022-04-05T23:18:46.890943Z",
     "shell.execute_reply": "2022-04-05T23:18:46.890506Z",
     "shell.execute_reply.started": "2022-04-05T23:09:44.622838Z"
    },
    "papermill": {
     "duration": 0.774367,
     "end_time": "2022-04-05T23:18:46.891096",
     "exception": false,
     "start_time": "2022-04-05T23:18:46.116729",
     "status": "completed"
    },
    "tags": []
   },
   "outputs": [],
   "source": [
    "with open('submission.csv', 'w') as myfile:\n",
    "\n",
    "    # prepare submission\n",
    "    wfolder = './yolov5/runs/detect/exp/labels/'\n",
    "    for f in os.listdir(wfolder):\n",
    "        fname = wfolder + f\n",
    "        xdat = pd.read_csv(fname, sep = ' ', header = None)\n",
    "        outline = f[:-4] + ' ' + ' '.join(list(xdat.apply(lambda s: convert(s), axis = 1)))\n",
    "        myfile.write(outline + '\\n')\n",
    "        \n",
    "myfile.close()        "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "id": "0742ca9e",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2022-04-05T23:18:48.391097Z",
     "iopub.status.busy": "2022-04-05T23:18:48.390339Z",
     "iopub.status.idle": "2022-04-05T23:18:49.150703Z",
     "shell.execute_reply": "2022-04-05T23:18:49.149934Z",
     "shell.execute_reply.started": "2022-04-05T23:09:46.305247Z"
    },
    "papermill": {
     "duration": 1.50935,
     "end_time": "2022-04-05T23:18:49.150888",
     "exception": false,
     "start_time": "2022-04-05T23:18:47.641538",
     "status": "completed"
    },
    "tags": []
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "53f253011 0.100472 61 669 961 57 0.106223 0 125 234 183 0.1082 96 696 928 126 0.108863 515 393 86 161 0.11459 31 0 167 209 0.120246 517 466 89 147\r\n",
      "aac893a91 0.108037 376 435 325 188\r\n",
      "796707dd7 0.235373 684 128 234 113\r\n",
      "cc3532ff6 0.100443 406 752 144 108 0.102479 405 87 4 89 0.107173 576 537 138 94 0.113459 256 498 179 211 0.114847 836 618 186 65 0.121121 154 544 248 115 0.125105 40 567 483 199\r\n",
      "2fd875eaa 0.101398 439 163 204 860 0.112546 807 440 216 323\r\n",
      "348a992bb 0.100572 0 10 440 298 0.101236 344 445 401 211\r\n",
      "f5a1f0358 0.102549 398 424 295 96\r\n"
     ]
    }
   ],
   "source": [
    "!cat submission.csv"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.12"
  },
  "papermill": {
   "default_parameters": {},
   "duration": 517.5005,
   "end_time": "2022-04-05T23:18:50.543723",
   "environment_variables": {},
   "exception": null,
   "input_path": "__notebook__.ipynb",
   "output_path": "__notebook__.ipynb",
   "parameters": {},
   "start_time": "2022-04-05T23:10:13.043223",
   "version": "2.3.3"
  },
  "widgets": {
   "application/vnd.jupyter.widget-state+json": {
    "state": {
     "091480d4a3c344e98cd329a608a236f3": {
      "model_module": "@jupyter-widgets/controls",
      "model_module_version": "1.5.0",
      "model_name": "HBoxModel",
      "state": {
       "_dom_classes": [],
       "_model_module": "@jupyter-widgets/controls",
       "_model_module_version": "1.5.0",
       "_model_name": "HBoxModel",
       "_view_count": null,
       "_view_module": "@jupyter-widgets/controls",
       "_view_module_version": "1.5.0",
       "_view_name": "HBoxView",
       "box_style": "",
       "children": [
        "IPY_MODEL_eb2abaf626f14ba2a957ce6d4c323730",
        "IPY_MODEL_1927ca493455410caa04061249a14515",
        "IPY_MODEL_11e8663928f548c881462b4d80f64ad8"
       ],
       "layout": "IPY_MODEL_2a92a828ee1a41f8ac4a9115c14d1b18"
      }
     },
     "11e8663928f548c881462b4d80f64ad8": {
      "model_module": "@jupyter-widgets/controls",
      "model_module_version": "1.5.0",
      "model_name": "HTMLModel",
      "state": {
       "_dom_classes": [],
       "_model_module": "@jupyter-widgets/controls",
       "_model_module_version": "1.5.0",
       "_model_name": "HTMLModel",
       "_view_count": null,
       "_view_module": "@jupyter-widgets/controls",
       "_view_module_version": "1.5.0",
       "_view_name": "HTMLView",
       "description": "",
       "description_tooltip": null,
       "layout": "IPY_MODEL_50a42c063c0e4ff69c96a1099437abf2",
       "placeholder": "​",
       "style": "IPY_MODEL_e262b22c85b449ff910217fbb4f19f35",
       "value": " 3373/3373 [00:24&lt;00:00, 148.68it/s]"
      }
     },
     "1927ca493455410caa04061249a14515": {
      "model_module": "@jupyter-widgets/controls",
      "model_module_version": "1.5.0",
      "model_name": "FloatProgressModel",
      "state": {
       "_dom_classes": [],
       "_model_module": "@jupyter-widgets/controls",
       "_model_module_version": "1.5.0",
       "_model_name": "FloatProgressModel",
       "_view_count": null,
       "_view_module": "@jupyter-widgets/controls",
       "_view_module_version": "1.5.0",
       "_view_name": "ProgressView",
       "bar_style": "success",
       "description": "",
       "description_tooltip": null,
       "layout": "IPY_MODEL_912ef52fb80d452887ad3203c7e19f38",
       "max": 3373.0,
       "min": 0.0,
       "orientation": "horizontal",
       "style": "IPY_MODEL_dab69d330cad44cbb5fd8064517da406",
       "value": 3373.0
      }
     },
     "2a92a828ee1a41f8ac4a9115c14d1b18": {
      "model_module": "@jupyter-widgets/base",
      "model_module_version": "1.2.0",
      "model_name": "LayoutModel",
      "state": {
       "_model_module": "@jupyter-widgets/base",
       "_model_module_version": "1.2.0",
       "_model_name": "LayoutModel",
       "_view_count": null,
       "_view_module": "@jupyter-widgets/base",
       "_view_module_version": "1.2.0",
       "_view_name": "LayoutView",
       "align_content": null,
       "align_items": null,
       "align_self": null,
       "border": null,
       "bottom": null,
       "display": null,
       "flex": null,
       "flex_flow": null,
       "grid_area": null,
       "grid_auto_columns": null,
       "grid_auto_flow": null,
       "grid_auto_rows": null,
       "grid_column": null,
       "grid_gap": null,
       "grid_row": null,
       "grid_template_areas": null,
       "grid_template_columns": null,
       "grid_template_rows": null,
       "height": null,
       "justify_content": null,
       "justify_items": null,
       "left": null,
       "margin": null,
       "max_height": null,
       "max_width": null,
       "min_height": null,
       "min_width": null,
       "object_fit": null,
       "object_position": null,
       "order": null,
       "overflow": null,
       "overflow_x": null,
       "overflow_y": null,
       "padding": null,
       "right": null,
       "top": null,
       "visibility": null,
       "width": null
      }
     },
     "35570c7bcb5146c88932c9ad0286d705": {
      "model_module": "@jupyter-widgets/base",
      "model_module_version": "1.2.0",
      "model_name": "LayoutModel",
      "state": {
       "_model_module": "@jupyter-widgets/base",
       "_model_module_version": "1.2.0",
       "_model_name": "LayoutModel",
       "_view_count": null,
       "_view_module": "@jupyter-widgets/base",
       "_view_module_version": "1.2.0",
       "_view_name": "LayoutView",
       "align_content": null,
       "align_items": null,
       "align_self": null,
       "border": null,
       "bottom": null,
       "display": null,
       "flex": null,
       "flex_flow": null,
       "grid_area": null,
       "grid_auto_columns": null,
       "grid_auto_flow": null,
       "grid_auto_rows": null,
       "grid_column": null,
       "grid_gap": null,
       "grid_row": null,
       "grid_template_areas": null,
       "grid_template_columns": null,
       "grid_template_rows": null,
       "height": null,
       "justify_content": null,
       "justify_items": null,
       "left": null,
       "margin": null,
       "max_height": null,
       "max_width": null,
       "min_height": null,
       "min_width": null,
       "object_fit": null,
       "object_position": null,
       "order": null,
       "overflow": null,
       "overflow_x": null,
       "overflow_y": null,
       "padding": null,
       "right": null,
       "top": null,
       "visibility": null,
       "width": null
      }
     },
     "50a42c063c0e4ff69c96a1099437abf2": {
      "model_module": "@jupyter-widgets/base",
      "model_module_version": "1.2.0",
      "model_name": "LayoutModel",
      "state": {
       "_model_module": "@jupyter-widgets/base",
       "_model_module_version": "1.2.0",
       "_model_name": "LayoutModel",
       "_view_count": null,
       "_view_module": "@jupyter-widgets/base",
       "_view_module_version": "1.2.0",
       "_view_name": "LayoutView",
       "align_content": null,
       "align_items": null,
       "align_self": null,
       "border": null,
       "bottom": null,
       "display": null,
       "flex": null,
       "flex_flow": null,
       "grid_area": null,
       "grid_auto_columns": null,
       "grid_auto_flow": null,
       "grid_auto_rows": null,
       "grid_column": null,
       "grid_gap": null,
       "grid_row": null,
       "grid_template_areas": null,
       "grid_template_columns": null,
       "grid_template_rows": null,
       "height": null,
       "justify_content": null,
       "justify_items": null,
       "left": null,
       "margin": null,
       "max_height": null,
       "max_width": null,
       "min_height": null,
       "min_width": null,
       "object_fit": null,
       "object_position": null,
       "order": null,
       "overflow": null,
       "overflow_x": null,
       "overflow_y": null,
       "padding": null,
       "right": null,
       "top": null,
       "visibility": null,
       "width": null
      }
     },
     "912ef52fb80d452887ad3203c7e19f38": {
      "model_module": "@jupyter-widgets/base",
      "model_module_version": "1.2.0",
      "model_name": "LayoutModel",
      "state": {
       "_model_module": "@jupyter-widgets/base",
       "_model_module_version": "1.2.0",
       "_model_name": "LayoutModel",
       "_view_count": null,
       "_view_module": "@jupyter-widgets/base",
       "_view_module_version": "1.2.0",
       "_view_name": "LayoutView",
       "align_content": null,
       "align_items": null,
       "align_self": null,
       "border": null,
       "bottom": null,
       "display": null,
       "flex": null,
       "flex_flow": null,
       "grid_area": null,
       "grid_auto_columns": null,
       "grid_auto_flow": null,
       "grid_auto_rows": null,
       "grid_column": null,
       "grid_gap": null,
       "grid_row": null,
       "grid_template_areas": null,
       "grid_template_columns": null,
       "grid_template_rows": null,
       "height": null,
       "justify_content": null,
       "justify_items": null,
       "left": null,
       "margin": null,
       "max_height": null,
       "max_width": null,
       "min_height": null,
       "min_width": null,
       "object_fit": null,
       "object_position": null,
       "order": null,
       "overflow": null,
       "overflow_x": null,
       "overflow_y": null,
       "padding": null,
       "right": null,
       "top": null,
       "visibility": null,
       "width": null
      }
     },
     "b07ed6c082834435a4893370354a5640": {
      "model_module": "@jupyter-widgets/controls",
      "model_module_version": "1.5.0",
      "model_name": "DescriptionStyleModel",
      "state": {
       "_model_module": "@jupyter-widgets/controls",
       "_model_module_version": "1.5.0",
       "_model_name": "DescriptionStyleModel",
       "_view_count": null,
       "_view_module": "@jupyter-widgets/base",
       "_view_module_version": "1.2.0",
       "_view_name": "StyleView",
       "description_width": ""
      }
     },
     "dab69d330cad44cbb5fd8064517da406": {
      "model_module": "@jupyter-widgets/controls",
      "model_module_version": "1.5.0",
      "model_name": "ProgressStyleModel",
      "state": {
       "_model_module": "@jupyter-widgets/controls",
       "_model_module_version": "1.5.0",
       "_model_name": "ProgressStyleModel",
       "_view_count": null,
       "_view_module": "@jupyter-widgets/base",
       "_view_module_version": "1.2.0",
       "_view_name": "StyleView",
       "bar_color": null,
       "description_width": ""
      }
     },
     "e262b22c85b449ff910217fbb4f19f35": {
      "model_module": "@jupyter-widgets/controls",
      "model_module_version": "1.5.0",
      "model_name": "DescriptionStyleModel",
      "state": {
       "_model_module": "@jupyter-widgets/controls",
       "_model_module_version": "1.5.0",
       "_model_name": "DescriptionStyleModel",
       "_view_count": null,
       "_view_module": "@jupyter-widgets/base",
       "_view_module_version": "1.2.0",
       "_view_name": "StyleView",
       "description_width": ""
      }
     },
     "eb2abaf626f14ba2a957ce6d4c323730": {
      "model_module": "@jupyter-widgets/controls",
      "model_module_version": "1.5.0",
      "model_name": "HTMLModel",
      "state": {
       "_dom_classes": [],
       "_model_module": "@jupyter-widgets/controls",
       "_model_module_version": "1.5.0",
       "_model_name": "HTMLModel",
       "_view_count": null,
       "_view_module": "@jupyter-widgets/controls",
       "_view_module_version": "1.5.0",
       "_view_name": "HTMLView",
       "description": "",
       "description_tooltip": null,
       "layout": "IPY_MODEL_35570c7bcb5146c88932c9ad0286d705",
       "placeholder": "​",
       "style": "IPY_MODEL_b07ed6c082834435a4893370354a5640",
       "value": "100%"
      }
     }
    },
    "version_major": 2,
    "version_minor": 0
   }
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
